/*************************************************************
 *Name:           Christopher Alexander
 *Email address:  alexanc2@onid.oregonstate.edu
 *Class name:     CS362
 *Assignment:     Assignment #3
 *Description:    This file (cardtest3.c) contains unit tests
                  for outpost card in dominion.c
 *************************************************************/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

#define NUM_UNIQUE_CARDS 27 //At least by my count this is right.


int main() {
   int i, n;
   int seed;
   int numPlayer = 2;
   int player;
   int bonus = 0;
   int choice1 = 0;
   int choice2 = 0;
   int choice3 = 0;
   int handPos = 0;
   int k[10] = {adventurer, council_room, feast, gardens, mine,
               remodel, smithy, village, outpost, great_hall};
   struct gameState testState;
   struct gameState preState;

   printf("\nTesting outpost in cardEffect():\n");

   for (n = 0; n < 500; n++) {
      for (i = 0; i < sizeof(struct gameState); i++){
         ((char*)&testState)[i] = (int) (Random() * 256);
      }
      seed = (int) (Random() * 1000);

      memset(&testState, 23, sizeof(struct gameState));   // clear the game state
      initializeGame(numPlayer, k, seed, &testState); // initialize a new game

      player = (int) (Random() * numPlayer); //Randomly choose player.
      testState.whoseTurn = player;  //Make it this player's turn.

      testState.handCount[player] = ((int) (Random() * 50)) + 1; //Player's starting hand size.
      testState.deckCount[player] = ((int) (Random() * 50)) + 3; //Plenty of cards to draw from.
      testState.hand[player][handPos] = outpost; //Make sure player has outpost in hand.

      memcpy(&preState, &testState, sizeof(struct gameState));

      cardEffect(outpost, choice1, choice2, choice3, &testState, handPos, &bonus);

      //Manually recreate what outpost card does.
      preState.outpostPlayed++;
      discardCard(handPos, player, &preState, 0);

      if (memcmp(&preState, &testState, sizeof(struct gameState)) != 0){
         printf("\tBUG FOUND TESTING outpost in cardEffect()\n");
      }
   }

   return 0;
}
